<template>
  <div class="invocie_edit">
    <van-sticky>
      <van-nav-bar title="设置" left-arrow @click-left="back" />
    </van-sticky>
    <van-cell-group>
      <van-field v-model="form.company" label="公 司" placeholder="公司名称（必填）" />
      <van-field v-model="form.taxNumber" label="税 号" placeholder="15-20位数字字母（必填）" />
      <van-field v-model="form.address" label="地 址" placeholder="公司地址" />
      <van-field v-model="form.phone" label="电话号码" placeholder="电话号码" />
      <van-field v-model="form.bank" label="开户银行" placeholder="开户银行名称" />
      <van-field v-model="form.bankAccount" label="银行账户" placeholder="银行账户号码" />
    </van-cell-group>
    <div class="btns row-between-center">
      <div class="btn btn_white" @click="delInvoice">删除</div>
      <div class="btn" @click="editInvoice">编辑</div>
    </div>
  </div>
</template>

<script>
import api from 'api/api'
export default {
  data () {
    return {
      chosenAddressId: '1',
      form: {

      },
    }
  },
  created () {
    this.getDetail()
  },
  methods: {
    getDetail () {
      api.riser({
        data: {
          id: this.$route.params.id
        }
      }).then(res => {
        this.form = res.data[0]
      })
    },
    editInvoice () {
      api.edtRise({
        data: this.form
      }).then(res => {
        this.$toast('编辑成功')
        this.back()
      })
    },
    delInvoice () {
      api.delRise({
        data: {
          id: this.$route.params.id
        }
      }).then(res => {
        this.$toast('删除成功')
        this.back()
      })
    },
    back () {
      window.history.go(-1)
    }
  }
}
</script>

<style lang="scss">
.invocie_edit {
  min-height: 100vh;
  // background-color: #f5f5f5;
  text-align: left;
  .btns {
    padding: 0.3rem;
    margin-top: 0.6rem;
  }
  .btn {
    width: 3.2rem;
    line-height: 0.76rem;

    text-align: center;
    background: linear-gradient(
      96deg,
      rgba(72, 143, 240, 1),
      rgba(51, 130, 239, 1)
    );
    border-radius: 0.45rem;
    margin: 0 auto;
    color: #fff;
    font-size: 0.36rem;
    &.btn_white {
      background: rgba(242, 242, 242, 1);
      color: #666;
      font-size: 0.36rem;
    }
  }

  .mb_18 {
    margin-bottom: 0.18rem;
  }
  .mb_105 {
    margin-bottom: 1.05rem;
  }
}
</style>